<template>
	<view class="container tab_container">

		<view>
			<view :class="tabtarIndex==0?'page':''" v-show="tabtarIndex==0">
				<Achievement ref="achievement"></Achievement>
			</view>
			<view :class="tabtarIndex==1?'page':''" v-show="tabtarIndex==1">
				<Schedule ref="schedule"></Schedule>
			</view>
			<view :class="tabtarIndex==2?'page':''" v-if="tabtarIndex==2">
				<Merchant ref="merchant"></Merchant>
			</view>
			<view :class="tabtarIndex==3?'page':''" v-if="tabtarIndex==3">
				<BusinessMy ref="businessMy"></BusinessMy>
			</view>
		</view>

		<tui-tabbar :current="tabtarIndex" @click="tabbarSwitch" backdropFilter backgroundColor="#fff" :tabBar="tabBar"
			color="#666" selectedColor="#2FCC71"></tui-tabbar>
	</view>
</template>

<script>
	import Achievement from "@/pages/business/achievement/index";
	import Schedule from "@/pages/business/schedule/index";
	import Merchant from "@/pages/business/merchant/index";
	import BusinessMy from "@/pages/business/businessMy/index";


	export default {
		data() {
			return {
				tabtarIndex: 0,
				tabBar: [{
						// pagePath: '/pages/business/businessMy/index',
						text: '业绩',
						iconPath: '/static/img/icon_achievement.png',
						selectedIconPath: '/static/img/icon_achievement_s.png',
						// num: 1,
						// isDot: false
					},
					{
						// pagePath: '/pages/business/businessMy/index',
						text: '日程',
						iconPath: '/static/img/icon_schedule.png',
						selectedIconPath: '/static/img/icon_schedule_s.png',
						// num: 1,
						// isDot: false
					},
					{
						// pagePath: '/pages/business/businessMy/index',
						text: '客户',
						iconPath: '/static/img/icon_business.png',
						selectedIconPath: '/static/img/icon_business_s.png',
						// num: 1,
						// isDot: false
					},
					{
						// pagePath: '/pages/business/businessMy/index',
						text: '我的',
						iconPath: '/static/img/icon_my.png',
						selectedIconPath: '/static/img/icon_my_s.png',
						// num: 2,
						// isDot: true
					}
				],
			}
		},
		components: {
			Achievement,
			Schedule,
			Merchant,
			BusinessMy
		},
		onLoad() {
			// getAchievementInfo().then(res => {
			// 	console.log(res)


			// })

		},
		methods: {
			tabbarSwitch(e) {
				console.log(e)
				this.tabtarIndex = e.index;
			}
		},
		//页面相关事件处理函数--监听用户下拉动作
		onPullDownRefresh: function() {
			console.log("business onPullDownRefresh")
			if (this.tabtarIndex === 0) {
				this.$refs.achievement.doOnPullDownRefresh();
			} else if (this.tabtarIndex === 1) {
				this.$refs.schedule.doOnPullDownRefresh();
			} else if (this.tabtarIndex === 2) {
				this.$refs.merchant.doOnPullDownRefresh();
			} else if (this.tabtarIndex === 3) {

			}
		},

		// 页面上拉触底事件的处理函数
		onReachBottom: function() {
			console.log("business onReachBottom")
			if (this.tabtarIndex === 0) {
				this.$refs.achievement.doOnReachBottom();
			} else if (this.tabtarIndex === 1) {
				this.$refs.schedule.doOnReachBottom();
			} else if (this.tabtarIndex === 2) {
				this.$refs.merchant.doOnReachBottom();
			} else if (this.tabtarIndex === 3) {

			}
		}
	}
</script>

<style>
	.tab_container{
		padding-bottom: env(safe-area-inset-bottom);
	}
</style>
